package org.domain.sigepac.session;

import org.domain.sigepac.Utils;
import org.domain.sigepac.Entity.Curso;
import org.domain.sigepac.home.EntityHomeSupport;
import org.domain.sigepac.repository.RepositorioCurso;
import org.jboss.seam.ScopeType;
import org.jboss.seam.annotations.Begin;
import org.jboss.seam.annotations.End;
import org.jboss.seam.annotations.FlushModeType;
import org.jboss.seam.annotations.In;
import org.jboss.seam.annotations.Name;
import org.jboss.seam.annotations.Scope;
import org.jboss.seam.international.StatusMessages;

@Name("cursoHome")
@Scope(ScopeType.CONVERSATION)
public class CursoHome extends EntityHomeSupport<Curso> {

	private static final long serialVersionUID = 1624266645825051326L;

	@In
	private StatusMessages statusMessages;
	
	@In
	private RepositorioCurso repositorioCurso;

	
	public CursoHome() {
		// TODO Auto-generated constructor stub
	}
	
	
	@Override
	protected Curso createInstance() {
		Curso curso=new Curso();
		return curso;
	}
	
		
	
	@End
	public void salvar(){
		
		//persist();
		repositorioCurso.inserir(getInstance());
		Utils.entityManagerFlush();
		createdMessage();
		
	}
		
	@Begin(flushMode=FlushModeType.MANUAL,join=true)
	public void setIdCurso(Integer id) {
	    setId(id);	   
	 }
	 
	public Integer getIdCurso() {
	    return (Integer) getId();
	  }

	public boolean isWired(){
		return getInstance().getId()!=null;
	}
}
